﻿<UserControl x:Class="EPE.WPF.UCDepartmentInfoList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="1024">
    
    <Grid>
        <Grid.Resources>
            <ResourceDictionary Source="Resources/TreeGridDictionary.xaml" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <Border Grid.Row="0" Height="470" Width="750" Style="{StaticResource MainBorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="120"></RowDefinition>
                    <RowDefinition Height="15"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <GroupBox Grid.RowSpan="2" Header="查询条件" Height="100" Width="730" HorizontalAlignment="Center"  Margin="5,10,5,0" Name="groupBox1" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0">
                    <Grid Style="{StaticResource BorderGridStyle}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="80"></ColumnDefinition>
                            <ColumnDefinition Width="120"></ColumnDefinition>
                            <ColumnDefinition Width="80"></ColumnDefinition>
                            <ColumnDefinition Width="120"></ColumnDefinition>
                            <ColumnDefinition Width="300"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"></RowDefinition>
                            <RowDefinition Height="10"></RowDefinition>
                            <RowDefinition Height="30"></RowDefinition>
                            <RowDefinition Height="10"></RowDefinition>
                            <RowDefinition Height="*"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Label Content="机构名称"  Name="lblDepartmentName"  Grid.Row="0" Grid.Column="0"   VerticalAlignment="Center" Style="{StaticResource LabelStyle}" />
                        <TextBox Name="txtDepartmentName" Grid.Row="0" Grid.Column="1"  VerticalAlignment="Center" Style="{StaticResource TextBoxStyle}" />
                        <Label Content="负责人姓名"  Name="lblPrincipalName"  Grid.Row="0" Grid.Column="2"   VerticalAlignment="Center" Style="{StaticResource LabelStyle}" />
                        <TextBox Name="txtPrincipalName" Grid.Row="0" Grid.Column="3"  VerticalAlignment="Center" Style="{StaticResource TextBoxStyle}" />
                        <StackPanel  Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="5" Orientation="Horizontal" >
                            <Button  Name="btnSearch" Click="btnSearch_Click" Style="{StaticResource ButtonStyle}">
                                <StackPanel Orientation="Horizontal" >
                                    <Image Source="/resources/image/close04.png" Stretch="Fill" Style="{StaticResource ButtonImageStyle}"></Image>
                                    <Label Content="查询" HorizontalAlignment="Center" Style="{StaticResource ButtonLabelStyle}"></Label>
                                </StackPanel>
                            </Button>

                            <Button   Name="btnAdd"  Click="btnAdd_Click" Style="{StaticResource ButtonStyle}" >
                                <StackPanel Orientation="Horizontal" >
                                    <Image Source="/resources/image/close08.png" Stretch="Fill" Style="{StaticResource ButtonImageStyle}"></Image>
                                    <Label Content="添加" HorizontalAlignment="Center" Style="{StaticResource ButtonLabelStyle}"></Label>
                                </StackPanel>
                            </Button>
                        </StackPanel>

                    </Grid>
                </GroupBox>
                <GroupBox Header="机构信息" Height="350" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center"  Margin="5,0,5,0" Name="groupBox2" VerticalAlignment="Top" Width="730">
                    <DataGrid  Style="{StaticResource DataGridStyle}" Margin="0,10,0,0" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="5" Height="350" Width="710" Name="dgDepartment" HorizontalAlignment="Center"   VerticalAlignment="Top"  AutoGenerateColumns="False" ItemsSource="{Binding}"  SelectionMode="Single" IsReadOnly="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn Visibility="Hidden" Binding="{Binding Id}"></DataGridTextColumn>
                            <DataGridTextColumn Header="机构名称" Width="100" Binding="{Binding DepartmentName}" ></DataGridTextColumn>
                            <DataGridTextColumn Header="负责人" Width="100" Binding="{Binding RespondentsName}" ></DataGridTextColumn>
                            <DataGridTextColumn Header="职位" Width="100" Binding="{Binding Position}"></DataGridTextColumn>
                            <DataGridTextColumn Header="办公电话" Width="100" Binding="{Binding OfficePhone}" ></DataGridTextColumn>
                            <DataGridTextColumn Header="上级" Width="100" Binding="{Binding ParentName}" ></DataGridTextColumn>
                            <DataGridTemplateColumn Header="操作">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Button  Style="{StaticResource DataRowButtonStyle}" Name="btnEdit" Click="btnEdit_Click"  >

                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="/resources/image/fk_bj.png"></Image>
                                                    <!--<Label Content="编辑"></Label>-->
                                                </StackPanel>
                                            </Button>
                                            <Button  Style="{StaticResource DataRowButtonStyle}" Name="btnDel" Click="btnDel_Click">
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="/resources/image/fk_cs.png"></Image>
                                                    <!--<Label Content="删除"></Label>-->
                                                </StackPanel>
                                            </Button>
                                        </StackPanel>

                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>

                    </DataGrid>
                </GroupBox>

                <TreeView Name="_list" Grid.Row="3" Margin="0" BorderThickness="0" VerticalAlignment="Stretch" Background="Transparent" ItemsSource="{Binding Children}" >
                    <TreeView.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                            <Border CornerRadius="0" Margin="1"  x:Name="back" MinWidth="70"
                                Background="Transparent" DataContext="{Binding}" >
                                <StackPanel Orientation="Horizontal" Margin="2">
                                    <TextBlock Text="{Binding Text}" Margin="2 0"/>
                                </StackPanel>
                            </Border>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                </TreeView>
            </Grid>

        </Border>
    </Grid>
</UserControl>
